//
//  YueStatusCell.m
//  Shengzhuli
//
//  Created by subook on 2017/10/24.
//  Copyright © 2017年 kamangkeji. All rights reserved.
//

#import "YueStatusCell.h"
#import "YueStatusModel.h"
#import "UIImage+Extension.h"


@interface YueStatusCell()

@property (nonatomic, strong)UIImageView *iconImageView;
@property (nonatomic, strong)UILabel *nameLabel;
@property (nonatomic, strong)UILabel *statusLabel;
@property (nonatomic, strong)UILabel *describLabel;
@property (nonatomic, strong)UILabel *moneyLabel;
@property (nonatomic, strong)UILabel *dateLabel;

@end

@implementation YueStatusCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createUI];
    }
    return self;
}
- (void) createUI {
    
    _iconImageView = [[UIImageView alloc] initWithFrame:(CGRectMake(10, 10, 100, 100))];
    _iconImageView.image = [UIImage imageNamed:@"beijngtu"];
    _iconImageView.layer.cornerRadius = 50;
    _iconImageView.layer.masksToBounds = YES;
    [self.contentView addSubview:_iconImageView];
    
    _nameLabel = [[UILabel alloc] initWithFrame:(CGRectMake(120, 10, 80, 30))];
    _nameLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:_nameLabel];
    
    _statusLabel = [[UILabel alloc] initWithFrame:(CGRectMake(ScreenW-80, 10, 60, 30))];
    _statusLabel.font = [UIFont systemFontOfSize:13];
    _statusLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_statusLabel];
    
    _describLabel = [[UILabel alloc] initWithFrame:(CGRectMake(120, 50, ScreenW-100, 30))];
    _describLabel.font = [UIFont systemFontOfSize:13];
    _describLabel.textColor = [UIColor lightGrayColor];
    _describLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:_describLabel];
    
    _moneyLabel = [[UILabel alloc] initWithFrame:(CGRectMake(120, 80, 200, 30))];
    _moneyLabel.textColor = [UIColor redColor];
    _moneyLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:_moneyLabel];
    
    _dateLabel = [[UILabel alloc] initWithFrame:(CGRectMake(ScreenW-130, 80, 120, 30))];
    _dateLabel.textColor = [UIColor grayColor];
    _dateLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:_dateLabel];
    
    
}

- (void)updateCellWithModel:(YueStatusModel *)model {

    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.portraitUrl]];
    self.nameLabel.text = model.macaName;
    self.describLabel.text = model.macaWorks;
    self.moneyLabel.text = [@"¥" stringByAppendingString:model.money];
    if ([model.status isEqualToString:@"1"]) {
        self.statusLabel.text = @"预约中";
    }else if ([model.status isEqualToString:@"2"]) {
        self.statusLabel.text = @"预约成功";
    }else if ([model.status isEqualToString:@"3"]) {
        self.statusLabel.text = @"预约失败";
    }else {
        self.statusLabel.text = @"";
    }
    NSTimeInterval _interval=[model.createDate doubleValue] / 1000.0;
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:_interval];
    NSDateFormatter *objDateformat = [[NSDateFormatter alloc] init];
    [objDateformat setDateFormat:@"yyyy-MM-dd HH:mm"];
    
    self.dateLabel.text = [objDateformat stringFromDate: date];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
